<?php
/**
 * $Id: vmcompetition.php 7 2010-04-26 20:05:00Z webbochsant $
 *  @package	Joomla
 *  @author Daniel Eliasson
* 	@copyright	Copyright (C) 2010 Stilero. All rights reserved.
* 	@license	GNU/GPL, see LICENSE.php
* 	Joomla! is free software. This version may have been modified pursuant
* 	to the GNU General Public License, and as distributed it includes or
* 	is derivative of works licensed under the GNU General Public License or
* 	other free or open source software licenses.
*/

// no direct access
defined('_JEXEC') or die('Restricted access'); 

/**
 * Hello Hello Controller
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
class VmcompetitionsControllerVmcompetition extends VmcompetitionsController
{
	/**
	 * constructor (registers additional tasks to methods)
	 * @return void
	 */
	function __construct()
	{
	    parent::__construct();
	 
	    // Register Extra tasks
	    $this->registerTask( 'add'  ,     'edit' );
	}
	
	/**
	 * display the edit form
	 * @return void
	 */
	function edit()
	{
	    JRequest::setVar( 'view', 'vmcompetition' );
	    JRequest::setVar( 'layout', 'form'  );
	    //Hide the menu when we are editing
	    JRequest::setVar('hidemainmenu', 1);
	    	    
	    parent::display();
	}
	
	/**
	 * save a record (and redirect to main page)
	 * @return void
	 */
	function save()
	{
	    $model = $this->getModel('vmcompetition');
	 
	    if ($model->store()) {
	        $msg = JText::_( 'Competition Saved!' );
	    } else {
	        $msg = JText::_( 'Error Saving Competition' );
	    }
	 
	    // Check the table in so it can be edited.... we are done with it anyway
	    $link = 'index.php?option=com_vmcompetition';
	    $this->setRedirect($link, $msg);
	}
	
	/**
	 * remove record(s)
	 * @return void
	 */
	function remove()
	{
	    $model = $this->getModel('vmcompetition');
	    if(!$model->delete()) {
	        $msg = JText::_( 'Error: One or More Competitions Could not be Deleted' );
	    } else {
	        $msg = JText::_( 'Competition(s) Deleted' );
	    }
	 
	    $this->setRedirect( 'index.php?option=com_vmcompetition', $msg );
	}
	/**
	 * cancel editing a record
	 * @return void
	 */
	function cancel()
	{
	    $msg = JText::_( 'Operation Cancelled' );
	    $this->setRedirect( 'index.php?option=com_vmcompetition', $msg );
	}
	
	
}

?>